package com.lyf.boot.core.service;

import cn.hutool.extra.spring.SpringUtil;
import com.lyf.boot.base.system.entity.SysClient;
import com.lyf.boot.core.model.LoginVo;
import com.lyf.boot.exception.ServiceException;

/**
 * @author Luyufan
 * @date 2024/1/11 09:02
 **/
public interface IAuthStrategy {

    String BASE_NAME = "AuthStrategy";

    /**
     * 登录
     */
    static LoginVo login(String body, SysClient client, String grantType) {
        // 授权类型和客户端id
        String beanName = grantType + BASE_NAME;
        if (!SpringUtil.getBeanFactory().containsBean(beanName)) {
            throw new ServiceException("授权类型不正确!");
        }
        IAuthStrategy instance = SpringUtil.getBean(beanName);
        return instance.login(body, client);
    }

    /**
     * 登录
     */
    LoginVo login(String body, SysClient client);
}
